<extend name="Base/common"/>
<block name="style">
<style type="text/css">

	.bd_center{
		width: 90%;
		height:50%;
		margin:auto;
		margin-top:10px;
	}

	.toux{
		width: 80px;
		height: 80px;
		border:5px solid #fff;
		border-radius: 50% 50%;
		float: left;
		margin-left: 3%;
		margin-top: 6%;
	}
	.toux img{
		width: 70px;
		height: 70px;
		border-radius: 50% 50%;
	}
	.details{
		float:left;
		width: 50%;
		height: 40px;
		margin-left: 4%;
		margin-top: 8%;
	}
	.tixian{
		float:left;
		width: 67%;
		height: 50px;
		margin-left: 4%;
		margin-top: 3%;
	}
	.tixian button{
		border: none;
		background: none;
		font-size: 14px;
		margin-right: 9%;

	}

   
</style>
</block>
<block name="body">

			<div class="bd_center" style="background:#FCFCFC">
				<p>保存二维码至手机，使用支付宝扫一扫即可将您的口碑二维码收银权限授予我们的平台哦</p>
				<img src="{:U('Admin/Public/qrcode?type=8&url='.$url)}">
			</div>

</block>



<block name="script">
<script>
wx.config({
    debug: false,
    appId: '{$weixinconfig.appId}',
    timestamp: '{$weixinconfig.timestamp}',
    nonceStr: '{$weixinconfig.nonceStr}',
    signature: '{$weixinconfig.signature}', 
    jsApiList: [
        'chooseImage',
        'previewImage',
        'uploadImage',
        'downloadImage',
        'getLocalImgData'
    ]
});
wx.ready(function () {
// 5.1 拍照、本地选图
    var images = {
        localId: [],
        serverId: []
    };

// 上传图片
    $(".up").click(function(){ 
        var path='';
        var that =$(this);
        images.localId = [];
        wx.chooseImage({
            count: 1, // 默认9
            sizeType: ['compressed'], // 可以指定是原图还是压缩图，默认二者都有
            // sourceType: [ 'camera'],
            sourceType: [ 'camera','album'], // 可以指定来源是相册还是相机，默认二者都有 'album',
            success: function (res) {  
                images.localId = res.localIds;
                if (images.localId.length == 0) {
                    alert('请先使用 chooseImage 接口选择图片');
                    return;
                }
                if(images.localId.length > 1) {
                    alert('目前仅支持单张图片上传,请重新上传');
                    images.localId = [];
                    return;
                }
                var i = 0, length = images.localId.length;
                images.serverId = [];
                function upload() {
                    wx.uploadImage({
                        localId: images.localId[i],
                        success: function (res) {
                            i++;
                            that.find('img.previewi').attr('src',images.localId[0]);
                            images.serverId.push(res.serverId);
                            that.find('input[type=hidden]').val(images.serverId[0]);
                            if (i < length) {
                                upload();
                            }
                        },
                        fail: function (res) {
                            alert(JSON.stringify(res));
                        }
                    });
                }
                upload();
            }
        });


        



    });
});


    </script>

</block>